package com.demo.day412;

public class ArrDemo {

    public static void f1(int people){
        int a = -1;
        if (people<3){
            System.out.println("输出错误，人数必须三人及以上！");
            return;
        }
        int b,c,d;
        int[] arr=new int[people];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = i+1;
        }

        for (int j = 0; j <= arr.length-3; j++) {
            b = arr[0];
            c = arr[1];
            d = arr[2];
            for (int i = 0; i <= arr.length-3; i++) {
                if (i != arr.length-3){
                    arr[i] = arr[i+3];
                }else {
                    arr[people - 3-j] = b;
                    arr[people - 2-j] = c;
                    arr[people - 1-j] = d;
                    break;
                }
            }
            if (j==arr.length-3){
                a = d - 1;
                break;
            }
        }

        System.out.println(a);
    }

    public static void main(String[] args) {
        f1(10);

    }
}
